﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using Sirenix.OdinInspector;
using Sirenix.OdinInspector.Editor;
using UnityEditor;
using UnityEngine;

public class TestOdinUndoWrapData : ScriptableObject
{
    public TestOdinUndoData data;
}

[Serializable]
public class TestOdinUndoData
{
    public int iValue;
}

public class TestPropertyTree : MonoBehaviour
{
    private TestOdinUndoData testOdinUndoData = new TestOdinUndoData();

    private PropertyTree _propertyTree;

    private PropertyTree propertyTree
    {
        get
        {
            if (_propertyTree == null)
            {
                _propertyTree = PropertyTree.Create(testOdinUndoWrapData);
            }

            return _propertyTree;
        }
    }

    private TestOdinUndoWrapData _testOdinUndoWrapData;

    private TestOdinUndoWrapData testOdinUndoWrapData
    {
        get
        {
            if (_testOdinUndoWrapData == null)
            {
                _testOdinUndoWrapData = ScriptableObject.CreateInstance<TestOdinUndoWrapData>();
                _testOdinUndoWrapData.data = testOdinUndoData;
            }

            return _testOdinUndoWrapData;
        }
    }

    private SerializedObject _serializedObject;

    public SerializedObject serializedObject
    {
        get
        {
            if (_serializedObject == null)
            {
                _serializedObject = new SerializedObject(testOdinUndoWrapData);
            }

            return _serializedObject;
        }
    }

    [OnInspectorGUI]
    public void OnInspector()
    {
        propertyTree.Draw(true);
    }

    public void Start()
    {
        if (Path.HasExtension("test.png"))
            Debug.Log("成功");
        
        
        if (!Path.HasExtension("test/tstst2"))
            Debug.Log("shibai");
    }
}
